# Maintainer: crapStone <crapstone01@gmail.com>
pkgname=mdbook
pkgver=0.4.40
pkgrel=0
pkgdesc="mdBook is a utility to create modern online books from Markdown files"
url="https://rust-lang.github.io/mdBook/"
arch="all"
license="MPL-2.0"
makedepends="rust cargo cargo-auditable"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/rust-lang/mdBook/archive/v$pkgver.tar.gz
	cargo-update.patch
	"
builddir="$srcdir/mdBook-$pkgver"

prepare() {
	default_prepare
	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release

	./target/release/mdbook completions bash > $pkgname.bash
	./target/release/mdbook completions fish > $pkgname.fish
	./target/release/mdbook completions zsh > $pkgname.zsh
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 target/release/mdbook "$pkgdir"/usr/bin/mdbook

	install -Dm644 $pkgname.bash "$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 $pkgname.fish "$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish
	install -Dm644 $pkgname.zsh "$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
d73e8c8144ac8d450bc94974b64cd0519c44002c000c5a60449e49035317e24572cecdb7e41df31d3af7e1bc0f342ed64a3ed09deae8cecdbb295edd87858827  mdbook-0.4.40.tar.gz
f0bddc29f4a8d8dc0010427b463a36bf8ff9649d25317b7140dccd7b547eed310baf46db3eecd833dbb0c7dc8995000bd3913df8ce36b412910fc174625b5d42  cargo-update.patch
"
